package com.like.banzipao.server.model

import com.fasterxml.jackson.annotation.JsonIgnore
import org.ktorm.database.Database
import org.ktorm.entity.Entity
import org.ktorm.entity.sequenceOf
import org.ktorm.schema.Table
import org.ktorm.schema.int
import org.ktorm.schema.varchar

interface User : Entity<User> {
    companion object : Entity.Factory<User>()

    var id: Int
    var name: String

    @get:JsonIgnore
    var password: String
    var token: String
    var roomCard: Int
}

object Users : Table<User>("t_user") {
    val id = int("id").primaryKey().bindTo { it.id }
    val name = varchar("name").bindTo { it.name }
    val password = varchar("password").bindTo { it.password }
    val token = varchar("token").bindTo { it.token }
    val roomCard = int("room_card").bindTo { it.roomCard }
}

val Database.users get() = this.sequenceOf(Users)